<?php
/**
 * Created by PhpStorm.
 * User: zw251y
 * Date: 11/20/2014
 * Time: 1:11 PM
 */

function getFullNameMap()
{
    $names = array();
    $handle = fopen("list.txt", "r");
    if ($handle) {
        while (($line = fgets($handle)) !== false) {
            $space = preg_split('#\s+#', $line, null, PREG_SPLIT_NO_EMPTY);
            $uid = $space[count($space) - 1];
            $name = substr($uid, 2, strlen($uid) - 13);
            #echo $name."\n";
            $name = str_replace(".", " ", $name);

            $space = preg_split('#\s+#', $name, null, PREG_SPLIT_NO_EMPTY);
            $lastName = $space[count($space) - 1];
            $names[$lastName] = $name;
            #echo $lastName." ls";
            #echo $names[$lastName] . "....\n";
            // process the line read.
        }
    } else {
        // error opening the file.
    }
    fclose($handle);
    return $names;
}

$names = getFullNameMap();
#echo $names['Connors'];